package com.adou.d7.Food;

import java.util.ArrayList;
import java.util.Scanner;

public class FoodManager {
    private ArrayList<Food> foods = new ArrayList<>();

    Scanner sc = new Scanner(System.in);

    // 商家上架商品
    public void add() {
        System.out.println("菜品上架");
        Food food = new Food();
        System.out.println("请输入菜品名：");
        String name = sc.next();
        food.setName(name);


        foods.add(food);
    }

    public void printAllFonds(ArrayList<Food> foods) {
        for (int i = 0; i < foods.size(); i++) {
            Food food = foods.get(i);
            System.out.println("菜品名称：" + food.getName());
        }
    }

    public void start() {
        System.out.println("欢迎来到商家管理后台");
        while (true) {
            System.out.println("1.上架菜品");
            System.out.println("2.预览菜品");
            System.out.println("3.退出");
            System.out.println("请选择操作命令：");
            String cmd = sc.next();
            switch (cmd) {
                case "1":
                    add();
                    break;
                case "2":
                    printAllFonds(foods);
                    break;
                case "3":
                    return;// 结束当前方法
                default:
                    System.out.println("输入有误，请重新输入！");
                    break;
            }
        }

    }
}
